package com.app.couponsharelife.utils

import androidx.databinding.BindingAdapter
import android.graphics.Bitmap
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions

/**
 * Created by guluwa on 2018/1/12.
 */


@BindingAdapter("android:src")
fun ImageView.setSrc(bitmap: Bitmap) {
    this.setImageBitmap(bitmap)
}

@BindingAdapter("android:src")
fun ImageView.setSrc(resId: Int) {
    this.setImageResource(resId)
}

@BindingAdapter("circleImageUrl")
fun ImageView.loadCircleImage(url: String?) {
    Glide.with(context)
            .load(url)
            .apply(RequestOptions().circleCrop())
            .into(this)
}

@BindingAdapter("bigImageUrl")
fun ImageView.loadBigImage(url: String?) {
    Glide.with(context)
            .load(url)
            .into(this)
}
